#ifndef THREAD_POOL_H
#define THREAD_POOL_H
#define _GNU_SOURCE
// #include <linux/if_tun.h>
#include <netinet/if_ether.h>
// #include <net/if.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#define DEBUG_PRINT(fmt, ...) printf("\033[32m[DEBUG]\033[0m " fmt "\n", ##__VA_ARGS__);
#define INFO_PRINT(fmt, ...) printf("\033[32m[INFO]\033[0m " fmt "\n", ##__VA_ARGS__);
#define ERROR_PRINT(fmt, ...) printf("\033[31m[INFO]\033[0m " fmt "\n", ##__VA_ARGS__);

typedef void (*task)();
struct thread
{
    int pipe_r;
    int pipe_w;
    pid_t id;
};
/**
 *ret  0 --- success
 *ret -1 --- failed
 */
int create_thread_runner(struct thread *t);
int add_task_into_thread_pool(struct thread *t, task tsk);
int stop_thread_pool(struct thread *t);
/**
 *分配堆内存 需要free
 */
struct thread *new_thread();

uint16_t __checksum(task tsk);
int __verify_checksum(task tsk, uint16_t chk_sum);
static size_t __get_task_check_sum(task tsk);
ssize_t __read_all(int fd, void *buf, size_t nbytes);
ssize_t __write_all(int fd, const void *buf, size_t count);
#endif